import 'package:flutter/material.dart';
import 'package:flutter_layout/app.dart';
import 'package:flutter_layout/base/routes.dart';
import 'package:flutter_layout/base/index.dart';
import 'package:get/get.dart';

class RouteAuthMiddleware extends GetMiddleware {
  // @override
  // int? priority = 0;

  RouteAuthMiddleware({priority});

  @override
  RouteSettings? redirect(String? route) {
    // Future.delayed(const Duration(seconds: 1), () =>
    // );
    logger.i("App.loginStatus=${App.loginStatus}");
    if (App.loginStatus == 1) {
      return null;
    }
    Get.snackbar("提示", "请先登录APP", duration: const Duration(seconds: 1), dismissDirection: DismissDirection.startToEnd);
    return const RouteSettings(name: Routes.login);
  }
}
